<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!-- 主体内容 -->
<div class="layui-fluid" >



    <form class="layui-form" id="form1">
        <div class="layui-card">
            <div class="layui-card-header"  style="color:#d02e25;font-family: '楷体'; ">
                添加组织人员
            </div>
            <div class="layui-card-body">
                <div class="layui-card-header"  style="color:#d02e25;font-family: '楷体'; ">
                    基本人员信息
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-inline">
                        <input type="text" name="sex" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">民族</label>
                    <div class="layui-input-inline">
                        <input type="text" name="nation" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>



                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">出生年月</label>
                    <div class="layui-input-inline">
                        <input type="text" name="born" id="birthday" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">身份证号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="idCard"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">籍贯</label>
                    <div class="layui-input-inline">
                        <input type="text" name="hrResiter"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">学历</label>
                    <div class="layui-input-inline">
                        <div class="layui-inline" style="width: 100%;">
                            <div class="layui-input-inline" style="width: 100%;">
                                <select name="education" id="education" lay-verify="required" lay-search="" style="width: 100%;">

                                </select>
                            </div>
                        </div>
                    </div>

                    <label class="layui-form-label">婚姻状况</label>
                    <div class="layui-input-inline">
                        <input type="text" name="marriage"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <input type="checkbox" name="work" id="work" title="是否退休">
                </div>



                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">家庭住址</label>
                    <div class="layui-input-inline" style="width: 35%;">
                        <input type="text" name="livein"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">手机号码&nbsp;</label>
                    <div class="layui-input-inline" >
                        <input type="text" name="telephone"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">毕业院校</label>
                    <div class="layui-input-inline" >
                        <input type="text" name="school"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">所学专业&nbsp;</label>
                    <div class="layui-input-inline"  >
                        <input type="text" name="major"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>




                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">电子邮箱</label>
                    <div class="layui-input-inline">
                        <input type="text" name="email"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">QQ</label>
                    <div class="layui-input-inline">
                        <input type="text" name="qq"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">微信</label>
                    <div class="layui-input-inline">
                        <input type="text" name="weixin"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>




                <div class="layui-card-header"  style="color:#d02e25;font-family: '楷体'; ">
                    党籍信息
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">入党日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="joinDate" id="joinDate" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">固定电话</label>
                    <div class="layui-input-inline">
                        <input type="text" name="ptelephone" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label"></label>
                    <div class="layui-input-inline">
                        <button style="margin-left: -111px;" type="button" class="layui-btn" id="uploadImgBtn">上传头像</button>
                        <div class="layui-upload-list" style="margin-top: -47px;">
                            <img class="layui-upload-img" style="height: 50px;" id="uploadImg"/>
                            <p id="uploadImgText"></p>
                        </div>
                        <input type="hidden" name="personalPhoto" value="" required/>
                    </div>
                </div>


                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">所在党支部</label>
                    <div class="layui-input-inline">
                        <div class="layui-inline" style="width: 100%;">
                            <div class="layui-input-inline" style="width: 100%;">
                                <select name="branch" id="branch" lay-verify="required" lay-search="" style="width: 100%;">

                                </select>
                            </div>
                        </div>
                    </div>

                    <label class="layui-form-label">人员类别</label>
                    <div class="layui-input-inline">
                        <input type="text" name="personCategory"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">党内职务</label>
                    <div class="layui-input-inline">
                        <input type="text" name="positionInparty"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                </div>









                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">转为正式党员日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="becomefullDate" id="becomefullDate" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">党费缴纳基数</label>
                    <div class="layui-input-inline">
                        <input type="text" name="partyMoney"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">党籍状态</label>
                    <div class="layui-input-inline">
                        <input type="text" name="membershipStatus"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">&nbsp;</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="isOut" id="isOut" title="是否长期在外党员">
                        <input type="checkbox" name="isFlow" id="isFlow" title="是否流动党员">
                        <input type="checkbox" name="isOutcontact" id="isOutcontact" title="是否失联党员">
                        <input type="checkbox" name="isCollegeOfficial" id="isCollegeOfficial" title="是否大学生村官">
                        <input type="checkbox" name="isTwoRepresents" id="isTwoRepresents" title="是否两代表一委员">
                    </div>
                </div>


                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">工作岗位</label>
                    <div class="layui-input-inline">
                        <input type="text" name="workplace"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">工作职称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="technicalTitle"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>


                    <label class="layui-form-label">行政职务</label>
                    <div class="layui-input-inline">
                        <input type="text" name="administrativePosition"  lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>


                </div>



                <div class="layui-form-item" style="margin-left: 440px;">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="ok">提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary" id="reset">重置</button>
                    </div>
                </div>


            </div>
        </div>
    </form>


</div>



<script type="application/javascript">
    // layui.use(['form','laydate'], function(){

    var form = layui.form;
    var laydate = layui.laydate;



    //执行一个laydate实例
    laydate.render({
        elem: '#time'
    });

    laydate.render({
        elem: '#birthday'
    });

    laydate.render({
        elem: '#joinDate'
    });

    laydate.render({
        elem: '#becomefullDate'
    });


    form.render();
//提交信息
    form.on('submit(ok)',function (data) {

        //将数据转换成是否
        if(data.field.isOut=="on"){
            data.field.isOut = "是";
        }else{
            data.field.isOut = "否";
        }

        if(data.field.work=="on"){
            data.field.work = "是";
        }else{
            data.field.work = "否";
        }

        if(data.field.isFlow=="on"){
            data.field.isFlow = "是";
        }else{
            data.field.isFlow = "否";
        }

        if(data.field.isOutcontact=="on"){
            data.field.isOutcontact = "是";
        }else{
            data.field.isOutcontact = "否";
        }

        if(data.field.isTwoRepresents=="on"){
            data.field.isTwoRepresents = "是";
        }else{
            data.field.isTwoRepresents = "否";
        }

        if(data.field.isCollegeOfficial=="on"){
            data.field.isCollegeOfficial = "是";
        }else{
            data.field.isCollegeOfficial = "否";
        }

        console.log(data.field);
        $.ajax({
            type:"post",
            url:"/ajax/party/admin/addperson",
            contentType : 'application/json;charset=utf-8',
            //设置请求头信息
            dataType:"json",
            data:JSON.stringify(data.field),
            success:function (res) {
                if(res.code==0){
                    layer.alert("OK");
                }else {
                    layer.alert("发生了一些小错误，提交失败！");
                }
            }
        })

        return false;
    })
    // });

</script>

<script>
    //显示搜索选择框

    $.post("/ajax/party/admin/branches",{
        check:1024
    },function (res) {
        if(res.code==0){
            //得到所有级别
            var names = new Array();
            for(var i=0;i<res.data.length;i++){
                names[i]=res.data[i].branchName;
            }
            //将等级动态显示到界面上
            for(var i=0;i<names.length;i++){
                document.getElementById("branch").options.add(new Option(names[i],names[i]));

            }

        }
        else{
            layer.alert("未知错误！");
        }
        form.render();
    });

    $.post("/ajax/party/education_degree",{
        check:1024
    },function (res) {
        if(res.code==0){
            //得到所有级别
            var names = new Array();
            for(var i=0;i<res.data.length;i++){
                names[i]=res.data[i].name;
            }
            //将等级动态显示到界面上
            for(var i=0;i<names.length;i++){
                document.getElementById("education").options.add(new Option(names[i],names[i]));

            }

        }
        else{
            layer.alert("未知错误！");
        }
        form.render();
    });
</script>

<script type="application/javascript">

    //上传图片
    var nowTime = new Date().getTime();
    layui.use('upload',function () {
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem:'#uploadImgBtn'  //绑定元素
            ,url:'/api/spfile/upload'  //上传接口
            ,data:{
                tableName: '入党申请表',
                index:nowTime
            }
            ,before: function(obj){
                obj.preview(function(index, file, result){
                    console.log(result);
                    $('#uploadImg').attr('src', result);
                });
            }
            ,done:function (res) {
                $("input[name=personalPhoto]").val(res.url);
            }
            ,error:function () {
                alert("nono");
            }
        });})
</script>

